package com.yyfax.pay.third.facade.quickpay;

import java.util.Date;
import java.util.HashMap;

import com.yyfax.pay.third.model.to.yyfax.*;
import org.apache.commons.lang.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yyfax.commons.lang.DateUtil;
import com.yyfax.commons.lang.NumberUtil;
import com.yyfax.framework.model.Content;
import com.yyfax.framework.model.Params;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.common.constants.QuickPayRspCode;
import com.yyfax.pay.common.enums.PayModeEnum;
import com.yyfax.pay.common.enums.PayRspCodeEnum;
import com.yyfax.pay.common.enums.PayTypeEnum;
import com.yyfax.pay.common.enums.PaymentEnum;
import com.yyfax.pay.common.exception.YYPayException;
import com.yyfax.pay.third.model.to.quickpay.AuthenticationQuickPayContent;
import com.yyfax.pay.third.model.to.quickpay.AuthenticationQuickPayParams;
import com.yyfax.pay.third.model.to.quickpay.PayOrderQuickPayContent;
import com.yyfax.pay.third.model.to.quickpay.PayOrderQuickPayParams;
import com.yyfax.pay.third.model.to.quickpay.QueryOrderQuickPayContent;
import com.yyfax.pay.third.model.to.quickpay.QueryOrderQuickPayParams;
import com.yyfax.pay.third.model.to.quickpay.QuickPayConstant;
import com.yyfax.pay.third.model.to.quickpay.SendAuthenticationVerifyCodeQuickPayContent;
import com.yyfax.pay.third.model.to.quickpay.SendAuthenticationVerifyCodeQuickPayParams;
import com.yyfax.pay.third.model.to.quickpay.SendVerifyCodeQuickPayContent;
import com.yyfax.pay.third.model.to.quickpay.SendVerifyCodeQuickPayParams;
import com.yyfax.pay.third.model.to.quickpay.xml.ErrorMsgContent;
import com.yyfax.pay.third.model.to.quickpay.xml.GetDynNumContent;
import com.yyfax.pay.third.model.to.quickpay.xml.IndAuthContent;
import com.yyfax.pay.third.model.to.quickpay.xml.IndAuthDynVerifyContent;
import com.yyfax.pay.third.model.to.quickpay.xml.QryTxnMsgContent;
import com.yyfax.pay.third.model.to.quickpay.xml.TxnMsgContent;
import com.yyfax.pay.third.service.PayInfoConstantService;
import com.yyfax.pay.third.service.TransformService;

/**
 * 快钱参数转换
 * <br/>
 * <br/>
 * 字段对应关系：
 * <br/>
 * externalRefNumber - orderId
 * <br/>
 * customerId - userId
 * <br/>
 * pan - cardNo
 * <br/>
 * cardHolderId - idNo
 * <br/>
 * cardHolderName - name
 * <br/>
 * refNumber - serialNo
 * 
 * @author xiemh
 * @date 2017-04-11 21:37:41
 * @since v1.0.0
 */
@Service("quickPayTransformService")
public class QuickPayTransformService implements TransformService {

	private Logger logger = LoggerFactory.getLogger(getClass());
	/** 证件类型 */
	private String ID_TYPE = "0";
	/** 特殊交易标记 */
	private String SP_FLAG = "QuickPay";
	/** 交易类型，PUR(消费) */
	private String TXN_TYPE = "PUR";

	@Autowired
	private PayInfoConstantService quickPayInfoUtil;

	@SuppressWarnings("unchecked")
	@Override
	public SendVerifyCodeQuickPayParams transformSendVerifyCodeParams(SendVerifyCodeYYParams req) throws Exception {
		QuickPayConstant constant = quickPayInfoUtil.getMerchantInfo(QuickPayConstant.class, req.getMerchantCode(), PaymentEnum.QUICK_PAY,
				PayTypeEnum.PAY, PayModeEnum.AUTH_PAY);

		String merchantId = constant.getMerchantId();

		GetDynNumContent getDynNum = new GetDynNumContent();
		getDynNum.setMerchantId(merchantId);
		getDynNum.setExternalRefNumber(req.getPayOrderId());

		getDynNum.setCustomerId(req.getUserId());
		getDynNum.setAmount(fen2yuanStr(req.getAmount()));

		// 是否再次投资
		if (req.isAgain()) {
			getDynNum.setStorablePan(storable(req.getCardNo()));
		} else {
			getDynNum.setCardHolderName(req.getName());
			getDynNum.setIdType(ID_TYPE);
			getDynNum.setCardHolderId(req.getIdNo());
			getDynNum.setPan(req.getCardNo());
			getDynNum.setPhoneNO(req.getPhone());
		}

		SendVerifyCodeQuickPayParams params = new SendVerifyCodeQuickPayParams();
		params.setMerchantCode(req.getMerchantCode());
		params.setGetDynNumContent(getDynNum);

		params.setReqUrl(constant.getSendSmsUrl());
		params.setReqContent(params.toXml());
		return params;
	}

	@Override
	@SuppressWarnings("unchecked")
	public QueryOrderQuickPayParams transformQueryPayOrderParams(QueryPayOrderYYParams req) throws Exception {
		QuickPayConstant constant = quickPayInfoUtil.getMerchantInfo(QuickPayConstant.class, req.getMerchantCode(), PaymentEnum.QUICK_PAY,
				PayTypeEnum.PAY, PayModeEnum.AUTH_PAY);

		String merchantId = constant.getMerchantId();
		String terminalId = constant.getTerminalId();
		String txnStatus = "";// 此处保持空字符串即可

		QryTxnMsgContent qryTxnMsgContent = new QryTxnMsgContent();
		qryTxnMsgContent.setExternalRefNumber(req.getOrderId());
		qryTxnMsgContent.setMerchantId(merchantId);
		qryTxnMsgContent.setTerminalId(terminalId);
		qryTxnMsgContent.setTxnType(TXN_TYPE);
		qryTxnMsgContent.setTxnStatus(txnStatus);

		QueryOrderQuickPayParams params = new QueryOrderQuickPayParams();
		params.setMerchantCode(req.getMerchantCode());
		params.setQryTxnMsgContent(qryTxnMsgContent);

		params.setReqUrl(constant.getQueryOrderUrl());
		params.setReqContent(params.toXml());
		return params;
	}

	@Override
	@SuppressWarnings("unchecked")
	public SendAuthenticationVerifyCodeQuickPayParams transformSendAuthenticationVerifyCodeParams(SendAuthenticationVerifyCodeYYParams req)
			throws Exception {
		QuickPayConstant constant = quickPayInfoUtil.getMerchantInfo(QuickPayConstant.class, req.getMerchantCode(), PaymentEnum.QUICK_PAY,
				PayTypeEnum.AUTH, PayModeEnum.AUTH_PAY);

		String merchantId = constant.getMerchantId();
		String terminalId = constant.getTerminalId();

		IndAuthContent indAuthContent = new IndAuthContent();
		indAuthContent.setMerchantId(merchantId);
		indAuthContent.setTerminalId(terminalId);
		indAuthContent.setIdType(ID_TYPE);

		indAuthContent.setCustomerId(req.getUserId());
		indAuthContent.setExternalRefNumber(req.getAuthOrderId());
		indAuthContent.setPan(req.getCardNo());
		indAuthContent.setCardHolderName(req.getName());
		indAuthContent.setCardHolderId(req.getIdNo());
		indAuthContent.setPhoneNO(req.getPhone());

		SendAuthenticationVerifyCodeQuickPayParams params = new SendAuthenticationVerifyCodeQuickPayParams();
		params.setMerchantCode(req.getMerchantCode());
		params.setIndAuthContent(indAuthContent);

		params.setReqUrl(constant.getAuthenticationSendSmsUrl());
		params.setReqContent(params.toXml());
		return params;
	}

	@Override
	@SuppressWarnings("unchecked")
	public AuthenticationQuickPayParams transformAuthenticationParams(AuthenticationYYParams req) throws Exception {
		QuickPayConstant constant = quickPayInfoUtil.getMerchantInfo(QuickPayConstant.class, req.getMerchantCode(), PaymentEnum.QUICK_PAY,
				PayTypeEnum.AUTH, PayModeEnum.AUTH_PAY);

		String merchantId = constant.getMerchantId();

		IndAuthDynVerifyContent indAuthDynVerifyContent = new IndAuthDynVerifyContent();
		indAuthDynVerifyContent.setMerchantId(merchantId);

		indAuthDynVerifyContent.setExternalRefNumber(req.getAuthOrderId());
		indAuthDynVerifyContent.setCustomerId(req.getUserId());
		indAuthDynVerifyContent.setPan(req.getCardNo());
		indAuthDynVerifyContent.setPhoneNO(req.getPhone());
		indAuthDynVerifyContent.setValidCode(req.getValidCode());
		indAuthDynVerifyContent.setToken(req.getToken());

		AuthenticationQuickPayParams params = new AuthenticationQuickPayParams();
		params.setMerchantCode(req.getMerchantCode());
		params.setIndAuthDynVerifyContent(indAuthDynVerifyContent);

		params.setReqUrl(constant.getAuthenticationUrl());
		params.setReqContent(params.toXml());
		return params;
	}

	@Override
	@SuppressWarnings("unchecked")
	public PayOrderQuickPayParams transformPayOrdeParams(PayOrderYYParams req) throws Exception {
		QuickPayConstant constant = quickPayInfoUtil.getMerchantInfo(QuickPayConstant.class, req.getMerchantCode(), PaymentEnum.QUICK_PAY,
				PayTypeEnum.PAY, PayModeEnum.AUTH_PAY);

		String merchantId = constant.getMerchantId();
		String terminalId = constant.getTerminalId();
		String tr3Url = constant.getNotifyUrl();
		// 支付的四个阶段，TR1：提交支付订单，TR2：同步返回支付结果，TR3：异步响应支付结果（快钱发起请求），TR4：异步响应支付结果确认（同步返回给快钱）
		String interactiveStatus = "TR1";

		TxnMsgContent txnMsgContent = new TxnMsgContent();
		txnMsgContent.setMerchantId(merchantId);
		txnMsgContent.setTerminalId(terminalId);
		txnMsgContent.setInteractiveStatus(interactiveStatus);
		txnMsgContent.setSpFlag(SP_FLAG);
		txnMsgContent.setTxnType(TXN_TYPE);
		txnMsgContent.setEntryTime(DateUtil.date2Str(new Date(), DateUtil.FORMAT_YYYYMMDDHHMMSS));
		txnMsgContent.setIdType(ID_TYPE);

		txnMsgContent.setStorableCardNo(storable(req.getCardNo()));
		txnMsgContent.setExternalRefNumber(req.getPayOrderId());
		txnMsgContent.setCustomerId(req.getUserId());
		txnMsgContent.setCardHolderId(req.getIdNo());
		txnMsgContent.setCardHolderName(req.getName());
		txnMsgContent.setCardNo(req.getCardNo());
		txnMsgContent.setTr3Url(tr3Url);
		txnMsgContent.setAmount(fen2yuanStr(req.getAmount()));

		// extMap内的每个map会被xml处理成独立节点
		HashMap<String, String> extMap = new HashMap<>();
		// 是否再次投资
		if (req.isAgain()) {
			extMap.put("payBatch", "2");
		} else {
			extMap.put("payBatch", "1");
			extMap.put("phone", req.getPhone());
		}
		extMap.put("savePciFlag", "1");
		extMap.put("validCode", req.getValidCode());
		extMap.put("token", req.getToken());
		txnMsgContent.setExtMap(extMap);

		PayOrderQuickPayParams params = new PayOrderQuickPayParams();
		params.setMerchantCode(req.getMerchantCode());
		params.setTxnMsgContent(txnMsgContent);

		params.setReqUrl(constant.getPayOrderUrl());
		params.setReqContent(params.toXml());
		return params;
	}

	@Override
	public <P extends Params> P transformBatchPayoutOrderCheckParams(QueryBatchPayoutOrderCheckYYParams req) {
		throw new NotImplementedException();
	}

	@Override
	public <P extends Params> P transformBatchPayoutOrderParams(PayoutBatchOrderYYParams req) {
		throw new NotImplementedException();
	}

	@Override
	public <P extends Params> P transformPayoutOrderParams(PayoutOrderYYParams rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <P extends Params> P transformQueryBatchPayoutOrderParams(QueryBatchPayoutOrderYYParams rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> SendVerifyCodeYYContent transformSendVerifyCodeContent(C rsp) throws Exception {
		SendVerifyCodeQuickPayContent quickPayContent = (SendVerifyCodeQuickPayContent) rsp;
		SendVerifyCodeYYContent content = new SendVerifyCodeYYContent();

		if (quickPayContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_PAY_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg("参数丢失");
			return content;
		}

		ErrorMsgContent errorMsgContent = quickPayContent.getErrorMsgContent();
		GetDynNumContent getDynNumContent = quickPayContent.getGetDynNumContent();
		if (errorMsgContent != null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_PAY_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg(errorMsgContent.getErrorMessage());
			return content;
		}

		if (getDynNumContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_PAY_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg("返回的GetDynNumContent节点为空");
			return content;
		} else if (!QuickPayRspCode.SUCCESS.equals(getDynNumContent.getResponseCode())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_PAY_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg(getDynNumContent.getResponseTextMessage());
			return content;
		}

		// 返回token结果
		content.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
		content.setResultMsg("获取成功");
		content.setToken(getDynNumContent.getToken());

		// 返回api请求的url,请求体,响应体
		content.setReqUrl(quickPayContent.getReqUrl());
		content.setReqContent(quickPayContent.getReqContent());
		content.setRspContent(quickPayContent.getRspContent());
		return content;
	}

	@Override
	public <C extends Content> QueryPayOrderYYContent transformQueryPayOrderContent(C rsp) throws Exception {
		QueryOrderQuickPayContent quickPayContent = (QueryOrderQuickPayContent) rsp;
		QueryPayOrderYYContent content = new QueryPayOrderYYContent();
		if (quickPayContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_QUERY_ORDER_FAIL.getValue());
			return content;
		}

		ErrorMsgContent errorMsgContent = quickPayContent.getErrorMsgContent();
		TxnMsgContent txnMsgContent = quickPayContent.getTxnMsgContent();

		if (txnMsgContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_QUERY_ORDER_FAIL.getValue());
			content.setResultMsg("返回的txnMsgContent节点为空");
			return content;
		} else if ("P".equals(txnMsgContent.getTxnStatus())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_DEALING.getValue());
			content.setResultMsg("订单处理中");
			return content;
		} else if ("F".equals(txnMsgContent.getTxnStatus())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue());
			content.setResultMsg("交易失败");
			return content;
		} else if (!"S".equals(txnMsgContent.getTxnStatus())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_QUERY_ORDER_FAIL.getValue());
			content.setResultMsg("快钱返回了无法识别的状态：" + txnMsgContent.getTxnStatus());
			return content;
		} else if (!QuickPayRspCode.SUCCESS.equals(txnMsgContent.getResponseCode())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_QUERY_ORDER_FAIL.getValue());
			content.setResultMsg(txnMsgContent.getResponseTextMessage());
			return content;
		}

		if (errorMsgContent != null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_QUERY_ORDER_FAIL.getValue());
			content.setResultMsg(errorMsgContent.getErrorMessage());
			return content;
		}

		// 返回content需要的结果
		content.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
		content.setResultMsg("查询成功");
		content.setOrderId(txnMsgContent.getExternalRefNumber());
		content.setSerialNo(txnMsgContent.getRefNumber());
		content.setAmount(yuan2fen(txnMsgContent.getAmount()));

		// 返回api请求的url,请求体,响应体
		content.setReqUrl(quickPayContent.getReqUrl());
		content.setReqContent(quickPayContent.getReqContent());
		content.setRspContent(quickPayContent.getRspContent());
		return content;
	}

	@Override
	public <C extends Content> SendAuthenticationVerifyCodeYYContent transformSendAuthenticationVerifyCodeContent(C rsp) {
		SendAuthenticationVerifyCodeQuickPayContent quickPayContent = (SendAuthenticationVerifyCodeQuickPayContent) rsp;
		SendAuthenticationVerifyCodeYYContent content = new SendAuthenticationVerifyCodeYYContent();
		if (quickPayContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_AUTH_VERIFY_CODE_FAIL.getValue());
			return content;
		}

		ErrorMsgContent errorMsgContent = quickPayContent.getErrorMsgContent();
		IndAuthContent indAuthContent = quickPayContent.getIndAuthContent();
		if (errorMsgContent != null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_AUTH_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg(errorMsgContent.getErrorMessage());
			return content;
		}

		if (indAuthContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_AUTH_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg("返回的indAuthContent节点为空");
			return content;
		} else if (!QuickPayRspCode.SUCCESS.equals(indAuthContent.getResponseCode())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_GET_AUTH_VERIFY_CODE_FAIL.getValue());
			content.setResultMsg(indAuthContent.getResponseTextMessage());
			return content;
		}

		// 返回所有需要的参数
		content.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
		content.setResultMsg("获取鉴权动态码成功");
		content.setToken(indAuthContent.getToken());

		return content;
	}

	@Override
	public <C extends Content> AuthenticationYYContent transformAuthenticationContent(C rsp) {
		AuthenticationQuickPayContent quickPayContent = (AuthenticationQuickPayContent) rsp;
		AuthenticationYYContent content = new AuthenticationYYContent();
		if (quickPayContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_AUTH_FAIL.getValue());
			return content;
		}

		ErrorMsgContent errorMsgContent = quickPayContent.getErrorMsgContent();
		IndAuthDynVerifyContent indAuthDynVerifyContent = quickPayContent.getIndAuthDynVerifyContent();
		if (errorMsgContent != null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_AUTH_FAIL.getValue());
			content.setResultMsg(errorMsgContent.getErrorMessage());
			return content;
		}

		if (indAuthDynVerifyContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_AUTH_FAIL.getValue());
			content.setResultMsg("返回的indAuthDynVerifyContent节点为空");
			return content;
		} else if (!QuickPayRspCode.SUCCESS.equals(indAuthDynVerifyContent.getResponseCode())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_AUTH_FAIL.getValue());
			content.setResultMsg(indAuthDynVerifyContent.getResponseTextMessage());
			return content;
		}

		content.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
		content.setResultMsg("鉴权成功");
		// content.setUserId(indAuthDynVerifyContent.getCustomerId());
		return content;
	}

	@Override
	public <C extends Content> PayOrderYYContent transformPayOrdeContent(C rsp) throws Exception {
		PayOrderQuickPayContent quickPayContent = (PayOrderQuickPayContent) rsp;
		PayOrderYYContent content = new PayOrderYYContent();
		if (quickPayContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue());
			return content;
		}

		ErrorMsgContent errorMsgContent = quickPayContent.getErrorMsgContent();
		TxnMsgContent txnMsgContent = quickPayContent.getTxnMsgContent();
		if (errorMsgContent != null) {
			if (QuickPayRspCode.UNGETBANKRESULT.equals(errorMsgContent.getErrorCode())
					|| QuickPayRspCode.INSIDE_DEALING.equals(errorMsgContent.getErrorCode())) {
				content.setResultCode(PayRspCodeEnum.PAY_CODE_DEALING.getValue());
				content.setResultMsg("订单处理中");
				return content;
			} else {
				content.setResultCode(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue());
				content.setResultMsg(errorMsgContent.getErrorMessage());
				return content;
			}
		}

		if (txnMsgContent == null) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue());
			content.setResultMsg("返回的txnMsgContent节点为空");
			return content;
		} else if (!QuickPayRspCode.SUCCESS.equals(txnMsgContent.getResponseCode())) {
			content.setResultCode(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue());
			content.setResultMsg(txnMsgContent.getResponseTextMessage());
			return content;
		}

		content.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
		content.setResultMsg("支付成功");
		content.setPayOrderId(txnMsgContent.getExternalRefNumber());
		content.setSerialNo(txnMsgContent.getRefNumber());
		content.setAmount(yuan2fen(txnMsgContent.getAmount()));

		// 返回api请求的url,请求体,响应体
		content.setReqUrl(quickPayContent.getReqUrl());
		content.setReqContent(quickPayContent.getReqContent());
		content.setRspContent(quickPayContent.getRspContent());
		return content;
	}

	@Override
	public <C extends Content> PayoutOrderYYContent transformPayoutOrderContent(C rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> QueryBatchPayoutOrderYYContent transformQueryBatchPayoutOrderContent(C req) {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> QueryBatchPayoutOrderCheckYYContent transformBatchPayoutOrderCheckContent(C rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> PayoutBatchOrderYYContent transformBatchPayoutOrderContent(C rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <P> P transformQueryCardBinParams(QueryCardBinParams rsp) {
		throw new NotImplementedException();
	}

	@Override
	public <C> QueryCardBinContent transformQueryCardBinContent(C req) {
		throw new NotImplementedException();
	}

	/**
	 * 缩略卡号（前6后4）
	 */
	public String storable(String cardNo) {
		return cardNo.substring(0, 6) + cardNo.substring(cardNo.length() - 4, cardNo.length());
	}

	/**
	 * 元转分
	 */
	private int yuan2fen(String amount) throws Exception {
		try {
			return new Long(NumberUtil.yuan2fen(Double.parseDouble(amount))).intValue();
		} catch (Exception e) {
			logger.info("amount转换出错,amount:{}", amount, e);
			throw new YYPayException(RspCodeEnum.COMMON_ERROR_UNKNOWN_EXCEPTION, "amount转换出错");
		}
	}

	/**
	 * 元转分
	 */
	private String fen2yuanStr(int amount) throws Exception {
		try {
			return String.valueOf(NumberUtil.fen2yuan(amount));
		} catch (Exception e) {
			logger.info("amount转换出错,amount:{}", amount, e);
			throw new YYPayException(RspCodeEnum.COMMON_ERROR_UNKNOWN_EXCEPTION, "amount转换出错");
		}
	}

	public static void main(String[] args) throws Exception {

		TxnMsgContent txnMsgContent = new TxnMsgContent();

		HashMap<String, String> extMap = new HashMap<>();
		extMap.put("key", "kkkkk");
		extMap.put("value", "vvvvvv");

		txnMsgContent.setExtMap(extMap);

		PayOrderQuickPayParams params = new PayOrderQuickPayParams();
		params.setTxnMsgContent(txnMsgContent);
		System.out.println(params.toXml());
	}

	@Override
	public <P extends Params> P transformQueryPayOutOrderParams(QueryPayoutOrderYYParams queryPayOutOrderYYParams) throws Exception {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> QueryPayoutOrderYYContent transformQueryPayOutOrderContent(C rsp) throws Exception {
		throw new NotImplementedException();
	}

	@Override
	public <P extends Params> P transformWithoutVerifyParams(WithoutVerifyYYParams withoutVerifyYYParams) throws Exception {
		throw new NotImplementedException();
	}

	@Override
	public <C extends Content> WithoutVerifyYYContent transformWithoutVerifyContent(C req) throws Exception {
		throw new NotImplementedException();
	}
}
